﻿var pageMain = new Sail.page({
    name     : "pageMain",                 //定义页面对象的唯一标识 名称
    mode     : "list",                     //这只页面对象的运行模式：列表页面
    isIframe : true,
    haveNavi : false,
    frames   : {
        name     : "frameMain",        	   //该frame对象的唯一标识
        title    : "空调选择",             //标题文本

        //-------------------------------------------------------------------------------
        //以JSON形式描述 frame 的构成(包含哪些 item)
        //-------------------------------------------------------------------------------
        items    : [
            {
              name  : "search",
              type  : "form", 
              title : "查询条件",
              isSearch : true,
              //"buttons"      : ["确定"],
              items : [
        					{
        						type:"combox", 
        						title:"空调类型",
        						dataIndex : "filter_EQS_other1",   
        						allowBlank:true,
        						root:"dataset.dictionary",
        						fieldText:"name",
        						fieldValue:"id",
										url: "../../dictionary.do?method=findDictionaryByTypeId&typeId="+COMBOX_MATERIEL_TYPE
                  },
                  {type:"input", title:"名称",   dataIndex:'filter_EQS_name'}
                ],
            
                layoutConfig : {
                    columns : 3
                },
                layout : [
                	{
                		items:[
                		   {'name':'空调类型'},
                		   {'name':'名称', colspan:2}
                		 ]
                  }
                ]
            },
            {
                name      : "gridMain",
                type      : "grid",
                title     : "空调列表",
                tbar      : ['确定','-'],
                pageSize:16,
                height:350,
                bindRelation   : {
                    root  : "dataset.dictionary",
                    id    : "id",
                    field : ["other1Id","other2Id"],
                    col   :[
                			{"header":"空调类型", "align":"left",  "width":80,   "dataIndex":"other1Name"    },
                			{"header":"空调名称", "align":"left",  "width":200,   "dataIndex":"name" },
                			{"header":"现存量", "align":"left",  "width":70,   "dataIndex":"stockAmount" },
                			{"header":"单位", "align":"left",  "width":55,   "dataIndex":"other2Name" }
                    ]
                    
                }
            }
        ],

        //-------------------------------------------------------------------------------
        //frame 的构成元素可以响应的事件的描述
        //-------------------------------------------------------------------------------
        bindEvent2Items : function(){   

            $('search').addButtonHandler('查询',function(){
        		    queryData();
            },$('search'));
            
            $('gridMain').addButtonHandler('确定',function(){
            	  var records = $('gridMain').getSelections();
            	  if(records && records.length) {
			    	    window.returnValue = records;
			     	    $('search').ownerFrame.close();
	    		}
	    		else {
	    			alert('请选择数据！');
	    		}
            });
        }        
    },
	//进入页面自动查询数据
	afterRun : function(){
		queryData();
	}
});

pageMain.run();

function queryData(){
	var searchInfo = $('search').getSearch();
	var url = "../../dictionary.do?method=list&filter_EQS_type="+COMBOX_MATERIEL_CLASS+searchInfo;
	$('gridMain').load(url);
}
    